package com.donfelix.animationdemo.share_elements;

import android.databinding.DataBindingUtil;
import android.transition.ChangeBounds;
import android.transition.Slide;
import android.view.Gravity;

import com.donfelix.animationdemo.R;
import com.donfelix.animationdemo.common.BaseDetailActivity;
import com.donfelix.animationdemo.common.Sample;
import com.donfelix.animationdemo.databinding.ActivitySharedelementBinding;

/**
 * Created by Don on 2017/3/23.
 * Desc
 */

public class SharedElementActivity extends BaseDetailActivity {
    private ActivitySharedelementBinding binding;
    private Sample sample;

    @Override
    protected void bindData() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_sharedelement);
        sample = (Sample) getIntent().getExtras().getSerializable(EXTRA_SAMPLE);
        binding.setSharedSample(sample);
    }

    @Override
    protected void setupWindowAinimation() {
        getWindow().getEnterTransition().setDuration(getResources().getInteger(R.integer.anim_duration_long));
    }

    @Override
    protected void setupLayout() {
        Slide slideTransition = new Slide(Gravity.LEFT);
        slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_long));
        SharedElementFragment1 sharedElementFragment1 = SharedElementFragment1.newInstance(sample);
        sharedElementFragment1.setReenterTransition(slideTransition);
        sharedElementFragment1.setExitTransition(slideTransition);
        sharedElementFragment1.setSharedElementEnterTransition(new ChangeBounds());
        getSupportFragmentManager().beginTransaction().replace(R.id.sample2_content, sharedElementFragment1).commit();
    }
}
